# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=rakudo-star
pkgver=2024.09
pkgrel=0
pkgdesc="Rakudo modules distribution"
url="https://rakudo.org/star/"
# riscv64: takes longer than the 45m timeout
arch="all !riscv64"
license="Artistic-2.0"
depends="libssl3 rakudo>$pkgver readline"
makedepends="bash perl-utils libffi-dev libuv-dev libxml2-dev zstd-dev"
# net: download missing dependencies, !check: no unified test suite
options="net !check"
source="https://github.com/rakudo/star/releases/download/$pkgver/rakudo-star-$pkgver.tar.gz
	rakudo-not-perl6.patch
	openssl-nativelib.patch
	use-newer-versions.patch
	reorder-modules.patch
	lock-depends-version.patch
	"
_prefixdir="$srcdir"/prefix
_rakudodir="$_prefixdir"/share/rakudo

prepare() {
	default_prepare

	install -dv "$_prefixdir"/bin "$_rakudodir"
	ln -sv /usr/bin/raku "$_prefixdir"/bin/
	ln -sv /usr/share/rakudo/core "$_rakudodir"/
}

build() {
	export RAKUDO_PREFIX="$_rakudodir"

	# This usually builds in around 20 minutes, but give it 45
	# to account for slow net/CPU load. Any more than that could
	# mean the build process has hung, and should be restarted.
	# Similar solutions are used for OpenJDK and Gitea/Forgejo.
	timeout 45m ./bin/rstar install -p "$_prefixdir" modules
}

package() {
	install -dv "$pkgdir"/usr/share/rakudo
	cp -a "$_rakudodir"/site "$pkgdir"/usr/share/rakudo/
}

sha512sums="
8b631cd0b4d50579987b4f1a9e3875dd988bc034d27311665c5da02a20b19e7b2fa56308260a3300563784be33201037aad01a169f1721852317641d7c6be833  rakudo-star-2024.09.tar.gz
c915cfab907b266d674e796b364ccc61d677773295c5962d5775faf7fab32f02d743c9b4f72d49890f94174481a5ec47c03409dcece0d71a4a0dbf4cf249de14  rakudo-not-perl6.patch
cee4eb863c9c6f66ee02e9d16171ad766daa881135c747e4b9b43b1e40442ed2384a6586f090dfe6014b48871873bb109ec76abf45447b72d9a2b5ab63d2e71d  openssl-nativelib.patch
29be28af0ce4ddd3d2f4f98a3acbc2684dd29aced756fa08e1ee0bade92af6fb5d786d180740c48abe41138cefcc9cf8a0a86d88248e98804070c875a15e07cc  use-newer-versions.patch
6b3b9afd40de4337446839b35a9e2e5a032a2fd817072ffafa7d71ce0331761b7c7005d8e286547be6f27ab83a7cdc7e5031aae978ed7c286fbed3f5d9bd135a  reorder-modules.patch
03b71414fe3cb650bcaf5f230ec32b1e879c670dcdd46cb07947f41048c02134559501e16f056ece0a41fb5b7e12e7551407adb95aa46eb9846b80944987bc3e  lock-depends-version.patch
"
